package com.jasypt.test;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.jasypt.encryption.StringEncryptor;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * 
	* Title: DecipheringtJasypt.java
	* Description: Jasypt  解密测试方案 ,EnableEncryptableProperties注解应该加载springboot 注解之前。
	* Copyright: Copyright (c) 2018
	* Company: Sco.Hee
	* @author Sco.Hee
	* @date 2018年9月14日
	* @version 1.0
 */
@EnableEncryptableProperties
@SpringBootTest(classes=Deserializers.Base.class)
@RunWith(SpringRunner.class)
public class DecipheringtJasypt {
    @Autowired
    StringEncryptor stringEncryptor;//密码解码器注入

    @Value("${spring.datasource.password}")
    private String password;

    @Value("${spring.datasource.username}")
    private String username;

    @org.junit.Test
    public void test() {
        System.out.println("解密后的数据库用户名:" + username);
        System.out.println("解密后的数据库密码:" + password);
    }
}